#pragma once
#ifndef BO_HPP
#define BO_HPP
#include <vector>
#include "Vertex.hpp"
#include "glad/glad.h"

class BO
{
public:
	uint32_t ID = 0;
	inline void Delete()
	{
		glDeleteBuffers(1, &ID);
	}
};

class VBO : public BO
{
public:
	inline VBO()
	{
		glGenBuffers(1, &ID);
	}
	inline void bind()
	{
		glBindBuffer(GL_ARRAY_BUFFER, ID);
	}
	inline void copy(std::vector<Vertex>& vertices)
	{
		glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * vertices.size(), &vertices[0], GL_STATIC_DRAW);
	}
	inline void bind_copy(std::vector<Vertex>& vertices)
	{
		bind();
		copy(vertices);
	}
};

class IBO : public BO
{
public:
	inline IBO()
	{
		glGenBuffers(1, &ID);
	}
	inline void bind()
	{
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
	}
	inline void copy(std::vector<uint32_t>& indices)
	{
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, 4 * indices.size(), &indices[0], GL_STATIC_DRAW);
	}
	inline void bind_copy(std::vector<uint32_t>& indices)
	{
		bind();
		copy(indices);
	}
};
#endif // BO_HPP